home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / term-source.lha / DatePanel.c < prev    next >
C/C++ Source or Header  |  1995-09-26  |  4KB  |  202 lines

  1. /*
  2. **    DatePanel.c
  3. **
  4. **    Editing panel for date selection
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. enum    {    GAD_MONTH=1,GAD_DAY,GAD_COMMENT,GAD_USE,GAD_CANCEL };
  13.  
  14. STATIC STRPTR __saveds
  15. ShowMonth(struct Gadget *SomeGadget,WORD Level)
  16. {
  17.     return(LocaleString(Level + MSG_DATEPANEL_JANUARY_TXT));
  18. }
  19.  
  20. BYTE __regargs
  21. DatePanel(struct TimeDateNode *Node)
  22. {
  23.     STATIC BYTE MaxDays[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  24.  
  25.     struct LayoutHandle    *Handle;
  26.     struct TimeDateNode     LocalNode;
  27.     BYTE             Result = FALSE;
  28.  
  29.     LocalNode = *Node;
  30.  
  31.     if(Handle = LT_CreateHandleTags(Window -> WScreen,
  32.         LH_LocaleHook,    &LocaleHook,
  33.         LH_ExitFlush,    FALSE,
  34.     TAG_DONE))
  35.     {
  36.         struct Window *PanelWindow;
  37.  
  38.         LT_New(Handle,
  39.             LA_Type,    VERTICAL_KIND,
  40.         TAG_DONE);
  41.         {
  42.             LT_New(Handle,
  43.                 LA_Type,    VERTICAL_KIND,
  44.                 LA_LabelID,    MSG_V36_0032,
  45.             TAG_DONE);
  46.             {
  47.                 LT_New(Handle,
  48.                     LA_Type,        SliderType,
  49.                     LA_LabelID,        MSG_DATEPANEL_MONTH_GAD,
  50.                     LA_HighLabel,        TRUE,
  51.                     LA_BYTE,        &LocalNode . Header . Month,
  52.                     LA_ID,            GAD_MONTH,
  53.                     LA_Chars,        16,
  54.                     GTSL_Max,        11,
  55.                     GTSL_LevelFormat,    "%s",
  56.                     GTSL_DispFunc,        ShowMonth,
  57.                     LASL_FullCheck,        TRUE,
  58.                 TAG_DONE);
  59.  
  60.                 LT_New(Handle,
  61.                     LA_Type,        SliderType,
  62.                     LA_LabelID,        MSG_DATEPANEL_DAY_GAD,
  63.                     LA_HighLabel,        TRUE,
  64.                     LA_BYTE,        &LocalNode . Header . Day,
  65.                     LA_ID,            GAD_DAY,
  66.                     GTSL_Min,        1,
  67.                     GTSL_Max,        MaxDays[LocalNode . Header . Month],
  68.                     LASL_FullCheck,        TRUE,
  69.                 TAG_DONE);
  70.  
  71.                 LT_New(Handle,
  72.                     LA_Type,    XBAR_KIND,
  73.                 TAG_DONE);
  74.  
  75.                 LT_New(Handle,
  76.                     LA_Type,    STRING_KIND,
  77.                     LA_LabelID,    MSG_GLOBAL_COMMENT_GAD,
  78.                     LA_STRPTR,    LocalNode . Header . Comment,
  79.                     GTST_MaxChars,    19,
  80.                 TAG_DONE);
  81.  
  82.                 LT_EndGroup(Handle);
  83.             }
  84.  
  85.             LT_New(Handle,
  86.                 LA_Type,VERTICAL_KIND,
  87.             TAG_DONE);
  88.             {
  89.                 LT_New(Handle,
  90.                     LA_Type,    XBAR_KIND,
  91.                     LAXB_FullSize,    TRUE,
  92.                 TAG_DONE);
  93.  
  94.                 LT_EndGroup(Handle);
  95.             }
  96.  
  97.             LT_New(Handle,LA_Type,HORIZONTAL_KIND,
  98.                 LAGR_SameSize,    TRUE,
  99.                 LAGR_Spread,    TRUE,
  100.             TAG_DONE);
  101.             {
  102.                 LT_New(Handle,
  103.                     LA_Type,    BUTTON_KIND,
  104.                     LA_LabelID,    MSG_GLOBAL_USE_GAD,
  105.                     LA_ID,        GAD_USE,
  106.                     LABT_ReturnKey,    TRUE,
  107.                     LABT_ExtraFat,    TRUE,
  108.                 TAG_DONE);
  109.  
  110.                 LT_New(Handle,
  111.                     LA_Type,    BUTTON_KIND,
  112.                     LA_LabelID,    MSG_GLOBAL_CANCEL_GAD,
  113.                     LA_ID,        GAD_CANCEL,
  114.                     LABT_EscKey,    TRUE,
  115.                     LABT_ExtraFat,    TRUE,
  116.                 TAG_DONE);
  117.  
  118.                 LT_EndGroup(Handle);
  119.             }
  120.  
  121.             LT_EndGroup(Handle);
  122.         }
  123.  
  124.         if(PanelWindow = LT_Build(Handle,
  125.             LAWN_TitleID,        MSG_DATEPANEL_DATE_SETTINGS_TXT,
  126.             LAWN_IDCMP,        IDCMP_CLOSEWINDOW,
  127.             LAWN_HelpHook,        &GuideHook,
  128.             LAWN_Parent,        Window,
  129.             WA_DepthGadget,        TRUE,
  130.             WA_CloseGadget,        TRUE,
  131.             WA_DragBar,        TRUE,
  132.             WA_RMBTrap,        TRUE,
  133.             WA_Activate,        TRUE,
  134.             WA_SimpleRefresh,    TRUE,
  135.         TAG_DONE))
  136.         {
  137.             struct IntuiMessage    *Message;
  138.             BOOLEAN             Done = FALSE;
  139.             ULONG             MsgClass;
  140.             struct Gadget        *MsgGadget;
  141.  
  142.             GuideContext(CONTEXT_DATE);
  143.  
  144.             LT_ShowWindow(Handle,TRUE);
  145.  
  146.             PushWindow(PanelWindow);
  147.  
  148.             do
  149.             {
  150.                 if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  151.                     break;
  152.  
  153.                 while(Message = (struct IntuiMessage *)LT_GetIMsg(Handle))
  154.                 {
  155.                     MsgClass    = Message -> Class;
  156.                     MsgGadget    = (struct Gadget *)Message -> IAddress;
  157.  
  158.                     LT_ReplyIMsg(Message);
  159.  
  160.                     if(MsgClass == IDCMP_CLOSEWINDOW)
  161.                         Done = TRUE;
  162.  
  163.                     if(MsgClass == IDCMP_MOUSEMOVE && MsgGadget -> GadgetID == GAD_MONTH)
  164.                     {
  165.                         LT_SetAttributes(Handle,GAD_DAY,
  166.                             GTSL_Max,    MaxDays[LocalNode . Header . Month],
  167.                         TAG_DONE);
  168.                     }
  169.  
  170.                     if(MsgClass == IDCMP_GADGETUP)
  171.                     {
  172.                         switch(MsgGadget -> GadgetID)
  173.                         {
  174.                             case GAD_USE:
  175.  
  176.                                 LT_UpdateStrings(Handle);
  177.  
  178.                                 *Node = LocalNode;
  179.  
  180.                                 Result = Done = TRUE;
  181.  
  182.                                 break;
  183.  
  184.                             case GAD_CANCEL:
  185.  
  186.                                 Done = TRUE;
  187.                                 break;
  188.                         }
  189.                     }
  190.                 }
  191.             }
  192.             while(!Done);
  193.  
  194.             PopWindow();
  195.         }
  196.  
  197.         LT_DeleteHandle(Handle);
  198.     }
  199.  
  200.     return(Result);
  201. }
  202.